4 * Abstract class to define pages for the web installer.
6 abstract class WebInstallerPage
{
9 * The WebInstaller object this WebInstallerPage belongs to.
15 public abstract function execute();
17 public function __construct( WebInstaller
$parent ) {
18 // TODO: This field is not defined??
19 $this->parent
= $parent;
22 public function addHTML( $html ) {
23 $this->parent
->output
->addHTML( $html );
26 public function startForm() {
28 "<div class=\"config-section\">\n" .
33 'action' => $this->parent
->getUrl( array( 'page' => $this->getName() ) )
39 public function endForm( $continue = 'continue' ) {
40 $this->parent
->output
->outputWarnings();
41 $s = "<div class=\"config-submit\">\n";
44 if ( $id === false ) {
45 $s .= Xml
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
49 // Fake submit button for enter keypress
50 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
51 array( 'name' => "enter-$continue", 'style' => 'display:none' ) ) . "\n";
55 $s .= Xml
::submitButton( wfMsg( 'config-back' ),
57 'name' => 'submit-back',
58 'tabindex' => $this->parent
->nextTabIndex()
63 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
65 'name' => "submit-$continue",
66 'tabindex' => $this->parent
->nextTabIndex(),
70 $s .= "</div></form></div>\n";
74 public function getName() {
75 return str_replace( 'WebInstaller_', '', get_class( $this ) );
78 public function getId() {
79 return array_search( $this->getName(), $this->parent
->pageSequence
);
82 public function getVar( $var ) {
83 return $this->parent
->getVar( $var );
86 public function setVar( $name, $value ) {
87 $this->parent
->setVar( $name, $value );
92 class WebInstaller_Language
extends WebInstallerPage
{
94 public function execute() {
96 $r = $this->parent
->request
;
97 $userLang = $r->getVal( 'UserLang' );
98 $contLang = $r->getVal( 'ContLang' );
100 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
102 $lifetime = 1440; // PHP default
105 if ( $r->wasPosted() ) {
107 if ( $this->parent
->getSession( 'test' ) === null ) {
108 $requestTime = $r->getVal( 'LanguageRequestTime' );
109 if ( !$requestTime ) {
110 // The most likely explanation is that the user was knocked back
111 // from another page on POST due to session expiry
112 $msg = 'config-session-expired';
113 } elseif ( time() - $requestTime > $lifetime ) {
114 $msg = 'config-session-expired';
116 $msg = 'config-no-session';
118 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
120 $languages = Language
::getLanguageNames();
121 if ( isset( $languages[$userLang] ) ) {
122 $this->setVar( '_UserLang', $userLang );
124 if ( isset( $languages[$contLang] ) ) {
125 $this->setVar( 'wgLanguageCode', $contLang );
129 } elseif ( $this->parent
->showSessionWarning
) {
130 # The user was knocked back from another page to the start
131 # This probably indicates a session expiry
132 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
135 $this->parent
->setSession( 'test', true );
137 if ( !isset( $languages[$userLang] ) ) {
138 $userLang = $this->getVar( '_UserLang', 'en' );
140 if ( !isset( $languages[$contLang] ) ) {
141 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
145 Xml
::hidden( 'LanguageRequestTime', time() ) .
146 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
147 $this->parent
->getHelpBox( 'config-your-language-help' ) .
148 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
149 $this->parent
->getHelpBox( 'config-wiki-language-help' );
152 $this->addHTML( $s );
157 * Get a <select> for selecting languages.
159 public function getLanguageSelector( $name, $label, $selectedCode ) {
160 global $wgDummyLanguageCodes;
161 $s = Xml
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
163 $languages = Language
::getLanguageNames();
165 $dummies = array_flip( $wgDummyLanguageCodes );
166 foreach ( $languages as $code => $lang ) {
167 if ( isset( $dummies[$code] ) ) continue;
168 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
170 $s .= "\n</select>\n";
171 return $this->parent
->label( $label, $name, $s );
176 class WebInstaller_Welcome
extends WebInstallerPage
{
178 public function execute() {
179 if ( $this->parent
->request
->wasPosted() ) {
180 if ( $this->getVar( '_Environment' ) ) {
184 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
185 $status = $this->parent
->doEnvironmentChecks();
187 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright', wfMsg( 'config-authors' ) ) );
195 class WebInstaller_DBConnect
extends WebInstallerPage
{
197 public function execute() {
198 $r = $this->parent
->request
;
199 if ( $r->wasPosted() ) {
200 $status = $this->submit();
201 if ( $status->isGood() ) {
202 $this->setVar( '_UpgradeDone', false );
205 $this->parent
->showStatusBox( $status );
211 $types = "<ul class=\"config-settings-block\">\n";
213 $defaultType = $this->getVar( 'wgDBtype' );
214 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
215 $installer = $this->parent
->getDBInstaller( $type );
219 $installer->getReadableName(),
223 $type == $defaultType,
224 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
229 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
230 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
231 $installer->getConnectForm() .
234 $types .= "</ul><br clear=\"left\"/>\n";
237 $this->parent
->label( 'config-db-type', false, $types ) .
244 public function submit() {
245 $r = $this->parent
->request
;
246 $type = $r->getVal( 'DBType' );
247 $this->setVar( 'wgDBtype', $type );
248 $installer = $this->parent
->getDBInstaller( $type );
250 return Status
::newFatal( 'config-invalid-db-type' );
252 return $installer->submitConnectForm();
257 class WebInstaller_Upgrade
extends WebInstallerPage
{
259 public function execute() {
260 if ( $this->getVar( '_UpgradeDone' ) ) {
261 if ( $this->parent
->request
->wasPosted() ) {
262 // Done message acknowledged
266 // Show the done message again
267 // Make them click back again if they want to do the upgrade again
268 $this->showDoneMessage();
273 // wgDBtype is generally valid here because otherwise the previous page
274 // (connect) wouldn't have declared its happiness
275 $type = $this->getVar( 'wgDBtype' );
276 $installer = $this->parent
->getDBInstaller( $type );
278 if ( !$installer->needsUpgrade() ) {
282 if ( $this->parent
->request
->wasPosted() ) {
284 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
285 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
286 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
288 $this->parent
->output
->flush();
289 $result = $installer->doUpgrade();
290 $this->addHTML( '</textarea>
291 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
292 $this->parent
->output
->flush();
294 $this->setVar( '_UpgradeDone', true );
295 $this->showDoneMessage();
301 $this->addHTML( $this->parent
->getInfoBox(
302 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
306 public function showDoneMessage() {
309 $this->parent
->getInfoBox(
310 wfMsgNoTrans( 'config-upgrade-done',
311 $GLOBALS['wgServer'] .
312 $this->getVar( 'wgScriptPath' ) . '/index' .
313 $this->getVar( 'wgScriptExtension' )
317 $this->endForm( 'regenerate' );
322 class WebInstaller_DBSettings
extends WebInstallerPage
{
324 public function execute() {
325 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
327 $r = $this->parent
->request
;
328 if ( $r->wasPosted() ) {
329 $status = $installer->submitSettingsForm();
330 if ( $status === false ) {
332 } elseif ( $status->isGood() ) {
335 $this->parent
->showStatusBox( $status );
339 $form = $installer->getSettingsForm();
340 if ( $form === false ) {
345 $this->addHTML( $form );
351 class WebInstaller_Name
extends WebInstallerPage
{
353 public function execute() {
354 $r = $this->parent
->request
;
355 if ( $r->wasPosted() ) {
356 if ( $this->submit() ) {
363 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
364 $this->setVar( 'wgSitename', '' );
367 // Set wgMetaNamespace to something valid before we show the form.
368 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
369 $metaNS = $this->getVar( 'wgMetaNamespace' );
370 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
373 $this->parent
->getTextBox( array(
374 'var' => 'wgSitename',
375 'label' => 'config-site-name',
377 $this->parent
->getHelpBox( 'config-site-name-help' ) .
378 $this->parent
->getRadioSet( array(
379 'var' => '_NamespaceType',
380 'label' => 'config-project-namespace',
381 'itemLabelPrefix' => 'config-ns-',
382 'values' => array( 'site-name', 'generic', 'other' ),
383 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
385 $this->parent
->getTextBox( array(
386 'var' => 'wgMetaNamespace',
388 'attribs' => array( 'disabled' => '' ),
390 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
391 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
392 $this->parent
->getTextBox( array(
393 'var' => '_AdminName',
394 'label' => 'config-admin-name'
396 $this->parent
->getPasswordBox( array(
397 'var' => '_AdminPassword',
398 'label' => 'config-admin-password',
400 $this->parent
->getPasswordBox( array(
401 'var' => '_AdminPassword2',
402 'label' => 'config-admin-password-confirm'
404 $this->parent
->getHelpBox( 'config-admin-help' ) .
405 $this->parent
->getTextBox( array(
406 'var' => '_AdminEmail',
407 'label' => 'config-admin-email'
409 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
410 $this->parent
->getCheckBox( array(
411 'var' => '_Subscribe',
412 'label' => 'config-subscribe'
414 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
415 $this->parent
->getFieldsetEnd() .
416 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
417 $this->parent
->getRadioSet( array(
418 'var' => '_SkipOptional',
419 'itemLabelPrefix' => 'config-optional-',
420 'values' => array( 'continue', 'skip' )
424 // Restore the default value
425 $this->setVar( 'wgMetaNamespace', $metaNS );
431 public function submit() {
433 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
434 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
435 '_Subscribe', '_SkipOptional' ) );
437 // Validate site name
438 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
439 $this->parent
->showError( 'config-site-name-blank' );
444 $nsType = $this->getVar( '_NamespaceType' );
445 if ( $nsType == 'site-name' ) {
446 $name = $this->getVar( 'wgSitename' );
447 // Sanitize for namespace
448 // This algorithm should match the JS one in WebInstallerOutput.php
449 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
450 $name = str_replace( '&', '&', $name );
451 $name = preg_replace( '/__+/', '_', $name );
452 $name = ucfirst( trim( $name, '_' ) );
453 } elseif ( $nsType == 'generic' ) {
454 $name = wfMsg( 'config-ns-generic' );
456 $name = $this->getVar( 'wgMetaNamespace' );
459 // Validate namespace
460 if ( strpos( $name, ':' ) !== false ) {
463 // Title-style validation
464 $title = Title
::newFromText( $name );
466 $good = $nsType == 'site-name' ?
true : false;
468 $name = $title->getDBkey();
473 $this->parent
->showError( 'config-ns-invalid', $name );
476 $this->setVar( 'wgMetaNamespace', $name );
478 // Validate username for creation
479 $name = $this->getVar( '_AdminName' );
480 if ( strval( $name ) === '' ) {
481 $this->parent
->showError( 'config-admin-name-blank' );
485 $cname = User
::getCanonicalName( $name, 'creatable' );
486 if ( $cname === false ) {
487 $this->parent
->showError( 'config-admin-name-invalid', $name );
490 $this->setVar( '_AdminName', $cname );
496 $pwd = $this->getVar( '_AdminPassword' );
497 $user = User
::newFromName( $cname );
498 $valid = $user->getPasswordValidity( $pwd );
499 if ( strval( $pwd ) === '' ) {
500 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
501 # This message is more specific and helpful.
502 $msg = 'config-admin-password-blank';
503 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
504 $msg = 'config-admin-password-mismatch';
505 } elseif ( $valid !== true ) {
506 # As of writing this will only catch the username being e.g. 'FOO' and
510 if ( $msg !== false ) {
511 $this->parent
->showError( $msg );
512 $this->setVar( '_AdminPassword', '' );
513 $this->setVar( '_AdminPassword2', '' );
521 class WebInstaller_Options
extends WebInstallerPage
{
523 public function execute() {
524 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
527 if ( $this->parent
->request
->wasPosted() ) {
528 if ( $this->submit() ) {
536 $this->parent
->getRadioSet( array(
537 'var' => '_RightsProfile',
538 'label' => 'config-profile',
539 'itemLabelPrefix' => 'config-profile-',
540 'values' => array_keys( $this->parent
->rightsProfiles
),
542 $this->parent
->getHelpBox( 'config-profile-help' ) .
545 $this->parent
->getRadioSet( array(
546 'var' => '_LicenseCode',
547 'label' => 'config-license',
548 'itemLabelPrefix' => 'config-license-',
549 'values' => array_keys( $this->parent
->licenses
),
550 'commonAttribs' => array( 'class' => 'licenseRadio' ),
552 $this->getCCChooser() .
553 $this->parent
->getHelpBox( 'config-license-help' ) .
556 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
557 $this->parent
->getCheckBox( array(
558 'var' => 'wgEnableEmail',
559 'label' => 'config-enable-email',
560 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
562 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
563 "<div id=\"emailwrapper\">" .
564 $this->parent
->getTextBox( array(
565 'var' => 'wgPasswordSender',
566 'label' => 'config-email-sender'
568 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
569 $this->parent
->getCheckBox( array(
570 'var' => 'wgEnableUserEmail',
571 'label' => 'config-email-user',
573 $this->parent
->getHelpBox( 'config-email-user-help' ) .
574 $this->parent
->getCheckBox( array(
575 'var' => 'wgEnotifUserTalk',
576 'label' => 'config-email-usertalk',
578 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
579 $this->parent
->getCheckBox( array(
580 'var' => 'wgEnotifWatchlist',
581 'label' => 'config-email-watchlist',
583 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
584 $this->parent
->getCheckBox( array(
585 'var' => 'wgEmailAuthentication',
586 'label' => 'config-email-auth',
588 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
590 $this->parent
->getFieldsetEnd()
593 $extensions = $this->parent
->findExtensions();
595 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
596 foreach( array_keys($extensions) as $ext ) {
597 $extHtml .= $this->parent
->getCheckBox( array(
602 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
603 $this->parent
->getFieldsetEnd();
604 $this->addHTML( $extHtml );
609 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
610 $this->parent
->getCheckBox( array(
611 'var' => 'wgEnableUploads',
612 'label' => 'config-upload-enable',
613 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
615 $this->parent
->getHelpBox( 'config-upload-help' ) .
616 '<div id="uploadwrapper" style="display: none;">' .
617 $this->parent
->getTextBox( array(
618 'var' => 'wgDeletedDirectory',
619 'label' => 'config-upload-deleted',
621 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
623 $this->parent
->getTextBox( array(
625 'label' => 'config-logo'
627 $this->parent
->getHelpBox( 'config-logo-help' )
629 $canUse = $this->getVar( '_ExternalHTTP' ) ?
630 'config-instantcommons-good' : 'config-instantcommons-bad';
632 $this->parent
->getCheckBox( array(
633 'var' => 'wgUseInstantCommons',
634 'label' => 'config-instantcommons',
636 $this->parent
->getHelpBox( 'config-instantcommons-help', wfMsgNoTrans( $canUse ) ) .
637 $this->parent
->getFieldsetEnd()
640 $caches = array( 'none' );
641 if( count( $this->getVar( '_Caches' ) ) ) {
644 $caches[] = 'memcached';
648 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
649 # Object cache settings
650 $this->parent
->getRadioSet( array(
651 'var' => 'wgMainCacheType',
652 'label' => 'config-cache-options',
653 'itemLabelPrefix' => 'config-cache-',
657 $this->parent
->getHelpBox( 'config-cache-help' ) .
658 '<div id="config-memcachewrapper">' .
659 $this->parent
->getTextBox( array(
660 'var' => '_MemCachedServers',
661 'label' => 'config-memcached-servers',
663 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
664 $this->parent
->getFieldsetEnd()
669 public function getCCPartnerUrl() {
671 $exitUrl = $wgServer . $this->parent
->getUrl( array(
673 'SubmitCC' => 'indeed',
674 'config__LicenseCode' => 'cc',
675 'config_wgRightsUrl' => '[license_url]',
676 'config_wgRightsText' => '[license_name]',
677 'config_wgRightsIcon' => '[license_button]',
679 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
680 '/skins/common/config-cc.css';
681 $iframeUrl = 'http://creativecommons.org/license/?' .
683 'partner' => 'MediaWiki',
684 'exit_url' => $exitUrl,
685 'lang' => $this->getVar( '_UserLang' ),
686 'stylesheet' => $styleUrl,
691 public function getCCChooser() {
692 $iframeAttribs = array(
693 'class' => 'config-cc-iframe',
694 'name' => 'config-cc-iframe',
695 'id' => 'config-cc-iframe',
700 if ( $this->getVar( '_CCDone' ) ) {
701 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
703 $iframeAttribs['src'] = $this->getCCPartnerUrl();
707 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
708 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
712 public function getCCDoneBox() {
713 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
714 // If you change this height, also change it in config.css
715 $expandJs = str_replace( '$1', '54em', $js );
716 $reduceJs = str_replace( '$1', '70px', $js );
719 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
721 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
723 "<p style=\"text-align: center\">" .
726 'href' => $this->getCCPartnerUrl(),
727 'onclick' => $expandJs,
729 wfMsg( 'config-cc-again' )
732 "<script type=\"text/javascript\">\n" .
733 # Reduce the wrapper div height
734 htmlspecialchars( $reduceJs ) .
739 public function submitCC() {
740 $newValues = $this->parent
->setVarsFromRequest(
741 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
742 if ( count( $newValues ) != 3 ) {
743 $this->parent
->showError( 'config-cc-error' );
746 $this->setVar( '_CCDone', true );
747 $this->addHTML( $this->getCCDoneBox() );
750 public function submit() {
751 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
752 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUpload', 'wgLogo',
753 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
754 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
755 'wgUseInstantCommons' ) );
757 if ( !in_array( $this->getVar( '_RightsProfile' ),
758 array_keys( $this->parent
->rightsProfiles
) ) )
760 reset( $this->parent
->rightsProfiles
);
761 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
764 $code = $this->getVar( '_LicenseCode' );
765 if ( $code == 'cc-choose' ) {
766 if ( !$this->getVar( '_CCDone' ) ) {
767 $this->parent
->showError( 'config-cc-not-chosen' );
770 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
771 $entry = $this->parent
->licenses
[$code];
772 if ( isset( $entry['text'] ) ) {
773 $this->setVar( 'wgRightsText', $entry['text'] );
775 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
777 $this->setVar( 'wgRightsUrl', $entry['url'] );
778 $this->setVar( 'wgRightsIcon', $entry['icon'] );
780 $this->setVar( 'wgRightsText', '' );
781 $this->setVar( 'wgRightsUrl', '' );
782 $this->setVar( 'wgRightsIcon', '' );
785 $exts = $this->parent
->getVar( '_Extensions' );
786 foreach( $exts as $key => $ext ) {
787 if( !$this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
788 unset( $exts[$key] );
791 $this->parent
->setVar( '_Extensions', $exts );
797 class WebInstaller_Install
extends WebInstallerPage
{
799 public function execute() {
800 if( $this->parent
->request
->wasPosted() ) {
802 } elseif( $this->getVar( '_InstallDone' ) ) {
804 $status = new Status();
805 $status->warning( 'config-install-alreadydone' );
806 $this->parent
->showStatusBox( $status );
809 $this->addHTML("<ul>");
810 $this->parent
->performInstallation(
811 array( $this, 'startStage'),
812 array( $this, 'endStage' )
814 $this->addHTML("</ul>");
820 public function startStage( $step ) {
821 $this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
824 public function endStage( $step, $status ) {
825 $success = $status->isGood();
826 $msg = $success ?
'config-install-step-done' : 'config-install-step-failed';
827 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
829 $html = "<span class=\"error\">$html</span>";
831 $this->addHTML( $html . "</li>\n" );
833 $this->parent
->showStatusBox( $status );
839 class WebInstaller_Complete
extends WebInstallerPage
{
841 public function execute() {
845 $this->parent
->getInfoBox(
846 wfMsgNoTrans( 'config-install-done',
847 $GLOBALS['wgServer'] . $this->parent
->getURL( array( 'localsettings' => 1 ) ),
848 $GLOBALS['wgServer'] .
849 $this->getVar( 'wgScriptPath' ) . '/index' .
850 $this->getVar( 'wgScriptExtension' )
854 $this->endForm( false );
858 class WebInstaller_Restart
extends WebInstallerPage
{
860 public function execute() {
861 $r = $this->parent
->request
;
862 if ( $r->wasPosted() ) {
863 $really = $r->getVal( 'submit-restart' );
865 $this->parent
->session
= array();
866 $this->parent
->happyPages
= array();
867 $this->parent
->settings
= array();
873 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
874 $this->addHTML( $s );
875 $this->endForm( 'restart' );
880 abstract class WebInstaller_Document
extends WebInstallerPage
{
882 protected abstract function getFileName();
884 public function execute() {
885 $text = $this->getFileContents();
886 $this->parent
->output
->addWikiText( $text );
888 $this->endForm( false );
891 public function getFileContents() {
892 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
895 protected function formatTextFile( $text ) {
896 $text = str_replace( array( '<', '{{', '[[' ),
897 array( '<', '{{', '[[' ), $text );
898 // replace numbering with [1], [2], etc with MW-style numbering
899 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
900 // join word-wrapped lines into one
903 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
904 } while ( $text != $prev );
905 // turn (bug nnnn) into links
906 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
907 // add links to manual to every global variable mentioned
908 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
909 // special case for <pre> - formatted links
912 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
913 } while ( $text != $prev );
917 private function replaceBugLinks( $matches ) {
918 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
919 $matches[1] . ' bug ' . $matches[1] . ']</span>';
922 private function replaceConfigLinks( $matches ) {
923 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
924 $matches[1] . ' ' . $matches[1] . ']</span>';
929 class WebInstaller_Readme
extends WebInstaller_Document
{
931 protected function getFileName() { return 'README'; }
933 public function getFileContents() {
934 return $this->formatTextFile( parent
::getFileContents() );
939 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
941 protected function getFileName() { return 'RELEASE-NOTES'; }
943 public function getFileContents() {
944 return $this->formatTextFile( parent
::getFileContents() );
949 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
951 protected function getFileName() { return 'UPGRADE'; }
953 public function getFileContents() {
954 return $this->formatTextFile( parent
::getFileContents() );
959 class WebInstaller_Copying
extends WebInstaller_Document
{
961 protected function getFileName() { return 'COPYING'; }
963 public function getFileContents() {
964 $text = parent
::getFileContents();
965 $text = str_replace( "\x0C", '', $text );
966 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
967 $text = '<tt>' . nl2br( $text ) . '</tt>';
971 private static function replaceLeadingSpaces( $matches ) {
972 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );